//
//  RentModel.m
//  PropertyManager
//
//  Created by TNG on 2018/9/4.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "RentModel.h"

@implementation RentModel

+(instancetype)modelWithDic:(NSDictionary *)dic
{
    return [[self alloc] initWithDic:dic];
}

-(instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if([key isEqualToString:@"id"])
    {
        _RentID = value;
    }
}

-(CGFloat)contentHeight
{
    CGFloat height = [_memo boundingRectWithSize:CGSizeMake(WIDTH - 30, MAXFLOAT) withTextFont:font(14)].height;
    return height;
}

-(CGFloat)monyeWidth
{
    CGFloat widht = [[NSString stringWithFormat:@"￥%@/月",_price] widthWithFont:font(16) constrainedToHeight:20];
    return widht;
}

-(CGFloat)titleHeight
{
    CGFloat height = [_title boundingRectWithSize:CGSizeMake(WIDTH - 30, MAXFLOAT) withTextFont:font(16)].height;
    if (height < 20) {
        height = 20;
    }
    return height;
}

-(CGFloat)detailHeight
{
    NSMutableString * str = [NSMutableString string];
    if (![[NSString stringWithFormat:@"%@",_housesize] isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@㎡ ",[NSString stringWithFormat:@"%@",_housesize]]];
    }
    if (![_estate isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@ ",_estate]];
    }
    if (![_livec isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@",_livec]];
    }
    CGFloat height = [str boundingRectWithSize:CGSizeMake(WIDTH - 30, MAXFLOAT) withTextFont:font(14)].height;
    return height;
}

@end
